LWin::
{
	hang:=0
	lie:=0
	count:=0
	clr10=0x704C30
	clr20=0x704C30
	clr30=0x704C30
	CoordMode, ToolTip,Relative
	MouseX:=18
	MouseY:=190
	pX:=MouseX
	pY:=MouseY
	class000=0
	loop,11
	{
		loop,19
		{
			ax:=pX+2
			ay:=pY+2
			bx:=pX+4
			bY:=pY+4
			PixelGetcolor, color1, %pX%, %pY%
			PixelGetcolor, color2, %ax%, %ay%
			PixelGetcolor, color3, %bx%, %by%
			i:=0
			c:=count+1
			Loop,%c%
			{
				if(clr1%i%==color1&&clr2%i%==color2&&clr3%i%==color3)
				{
					array%hang%%lie%:=i
					num:=class%i%00
					class%i%%num%hang:=hang
					class%i%%num%lie:=lie
					class%i%00:=class%i%00+1

					break
				}
				if(i==count)
				{
					count:=count+1
					array%hang%%lie%:=count
					clr1%count%:=color1
					clr2%count%:=color2
					clr3%count%:=color3
					class%count%00:=1
					class%count%0hang:=hang
					class%count%0lie:=lie

				}
				i:=i+1
			}
			pX:=pX+31
			lie:=lie+1
		}
		lie:=0
		pX:=MouseX
		pY:=pY+35
		hang:=hang+1
	}
	pY:=MouseY
	Return
}

1::
2::
3::
4::
5::
6::
7::
8::
9::
{

	z:=1
	Loop
	{
		a=%z%
		if(A_ThisHotkey==a)
		{
		Break
		}

		z++

	}

	loop,%z%
	{
		i:=1
		loop
		{
			j:=0

			if(i>count)
			{
			i:=1
			}
			num:=class%i%00
			if(num==0)
			{
				i++
				Continue
			}

			loop,%num%
			{
				y:=num-j
				x:=j+1
				loop
				{
					if(class%i%%j%hang!=99)
					Break
					j++
				}

				Loop,%y%
				{
					loop
				{
					if(class%i%%x%hang!=99&&x!=j)
					Break
					x++
				}
					hang0:=class%i%%j%hang
					lie0:=class%i%%j%lie
					hang1:=class%i%%x%hang
					lie1:=class%i%%x%lie
					temp:=class%i%%j%hang
					var:=sameline(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
					if(var==1)
					{

						array%hang0%%lie0%:=0
						array%hang1%%lie1%:=0
						class%i%00:=class%i%00-2
						clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
						class%i%%j%hang:=99
						class%i%%x%hang:=99
						goto, Label0
					}



					Loop
					{

						temp++
						if(temp>10)
						Break
						if(array%temp%%lie0%!=0)
						Break
						var:=sameline(temp,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
						if(var==1)
						{
							array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
							class%i%%j%hang:=99
							class%i%%x%hang:=99
							goto, Label0
						}
						tmp:=class%i%%x%hang
						Loop
						{

							tmp++
							if(tmp>10)
							Break
							if(array%tmp%%lie1%!=0)
						Break
							var:=sameline(temp,class%i%%j%lie,tmp,class%i%%x%lie)
							if(var==1)
							{
								array%hang0%%lie0%:=0
								array%hang1%%lie1%:=0
								class%i%00:=class%i%00-2
								clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}
						tmp:=class%i%%x%hang
						Loop
						{

							tmp--
							if(tmp<0)
							Break
							if(array%tmp%%lie1%!=0)
						Break
							var:=sameline(temp,class%i%%j%lie,tmp,class%i%%x%lie)
							if(var==1)
							{
								array%hang0%%lie0%:=0
								array%hang1%%lie1%:=0
								class%i%00:=class%i%00-2
								clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}

					}




					temp:=class%i%%j%hang
					Loop
					{


						temp--
						if(temp<0)
						break
						if(array%temp%%lie0%!=0)
						Break
						var:=sameline(temp,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
						if(var==1)
						{
							array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
							class%i%%j%hang:=99
							class%i%%x%hang:=99
							goto, Label0
						}
						tmp:=class%i%%x%hang
						Loop
						{

							tmp++
							if(tmp>10)
							Break
							if(array%tmp%%lie1%!=0)
						Break
							var:=sameline(temp,class%i%%j%lie,tmp,class%i%%x%lie)
							if(var==1)
							{
								array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}
						tmp:=class%i%%x%hang
						Loop
						{

							tmp--
							if(tmp<0)
							break
							if(array%tmp%%lie1%!=0)
						Break
							var:=sameline(temp,class%i%%j%lie,tmp,class%i%%x%lie)
							if(var==1)
							{
								array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
								clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}

					}



					temp:=class%i%%j%lie
					Loop
					{

						temp++
						if(temp>18)
						break
						if(array%hang0%%temp%!=0)
						Break
						var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,class%i%%x%lie)
						if(var==1)
						{
							array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
							class%i%%j%hang:=99
							class%i%%x%hang:=99
							goto, Label0
						}
						tmp:=class%i%%x%lie
						Loop
						{

							tmp++
							if(tmp>18)
							Break
							if(array%hang1%%tmp%!=0)
						Break
							var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,tmp)
							if(var==1)
							{
								array%hang0%%lie0%:=0
								array%hang1%%lie1%:=0
								class%i%00:=class%i%00-2
								clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}
						tmp:=class%i%%x%lie
						Loop
						{

							tmp--
							if(tmp<0)
							break
							if(array%hang1%%tmp%!=0)
						Break
							var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,tmp)
							if(var==1)
							{
								array%hang0%%lie0%:=0
								array%hang1%%lie1%:=0
								class%i%00:=class%i%00-2
								clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
								class%i%%j%hang:=99
								class%i%%x%hang:=99
								goto, Label0
							}

						}

					}




					temp:=class%i%%j%lie
					Loop
					{

					temp--
					if(temp<0)
					break
					if(array%hang0%%temp%!=0)
					Break
					var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,class%i%%x%lie)
					if(var==1)
					{
						array%hang0%%lie0%:=0
						array%hang1%%lie1%:=0
						class%i%00:=class%i%00-2
						clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
						class%i%%j%hang:=99
						class%i%%x%hang:=99
						goto, Label0
					}
					tmp:=class%i%%x%lie
					Loop
					{

						tmp++
						if(tmp>18)
						Break
						if(array%hang1%%tmp%!=0)
						Break
						var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,tmp)
						if(var==1)
						{
						array%hang0%%lie0%:=0
						array%hang1%%lie1%:=0
						class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
							class%i%%j%hang:=99
							class%i%%x%hang:=99
							goto, Label0
						}

					}
					tmp:=class%i%%x%lie
					Loop
					{

						tmp--
						if(tmp<0)
						Break
						if(array%hang1%%tmp%!=0)
						Break
						var:=sameline(class%i%%j%hang,temp,class%i%%x%hang,tmp)
						if(var==1)
						{
							array%hang0%%lie0%:=0
							array%hang1%%lie1%:=0
							class%i%00:=class%i%00-2
							clk(class%i%%j%hang,class%i%%j%lie,class%i%%x%hang,class%i%%x%lie)
							class%i%%j%hang:=99
							class%i%%x%hang:=99
							goto, Label0
						}

					}

					}

					x++
				}
				j++
			}
			i++
		}
	Label0:
		null=null
	}

}
sameline(hang1,lie1,hang2,lie2)
{
	if(lie1==lie2)
	{

		temp:=hang1
		loop
		{
			if(temp==10)
			break
			temp++
			if(temp==hang2)
			return 1
			if(array%temp%%lie1%!=0||temp>9)
			break
		}
		temp:=hang1
		loop
		{
			if(temp==0)
			break
			temp--
			if(temp==hang2)
			return 1
			if(array%temp%%lie1%!=0||temp<1)
			break
		}
	}
	if(hang1==hang2)
	{
		temp:=lie1
		loop
		{
			if(temp==18)
			break
			temp++
			if(temp==lie2)
			return 1
			if(array%hang1%%temp%!=0||temp>17)
			break
		}
		temp:=lie1
		loop
		{
			if(temp==0)
			break
			temp--
			if(temp==lie2)
			return 1
			if(array%hang1%%temp%!=0||temp<1)
			break
		}
	}
	return 0
}
clk(hang1,lie1,hang2,lie2)
{
	x1:=18+lie1*31
	x2:=18+lie2*31
	y1:=190+hang1*35
	y2:=190+hang2*35
	MouseMove,x1,y1
	sleep,5
	MouseClick
	sleep,300
	MouseMove,x2,y2
	sleep,5
	MouseClick

}









